package br.ucb.cm.board.bean;

import br.ucb.cm.config.bean.PieceConfig;

public class Move {
	private PieceConfig piece;
	private Location source;
	private Location destination;
	
	public Move(PieceConfig piece, Location source, Location destination) {
		this.piece = piece;
		this.source = source;
		this.destination = destination;
	}
	
	public PieceConfig getPiece() {
		return piece;
	}
	public void setPiece(PieceConfig piece) {
		this.piece = piece;
	}
	public Location getSource() {
		return source;
	}
	public void setSource(Location source) {
		this.source = source;
	}
	public Location getDestination() {
		return destination;
	}
	public void setDestination(Location destination) {
		this.destination = destination;
	}
	
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((destination == null) ? 0 : destination.hashCode());
		result = prime * result + ((piece == null) ? 0 : piece.hashCode());
		result = prime * result + ((source == null) ? 0 : source.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Move other = (Move) obj;
		if (destination == null) {
			if (other.destination != null)
				return false;
		} else if (!destination.equals(other.destination))
			return false;
		if (piece == null) {
			if (other.piece != null)
				return false;
		} else if (!piece.equals(other.piece))
			return false;
		if (source == null) {
			if (other.source != null)
				return false;
		} else if (!source.equals(other.source))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "Move [piece=" + piece + ", source=" + source + ", destination="
				+ destination + "]";
	}
	
}
